<?php
/**
 * Created by PhpStorm.
 * User: Happy
 * Date: 2016/7/18 0018
 * Time: 12:25
 */
//公历农历转化组件
class date_switchPlugin extends Plugin{

    public  function  __construct($path='')
    {
        parent::__construct($path);
        $path=$this->c('plugin_path');
        $lib_path=$path.'/lib/Lunar2.php';
        include($lib_path);
    }
    //公历转为农历  参数为时间戳
    public  function  generalToLunar($timestamp){
        $lunar=new Lunar();
        $date=date('Y-m-d',$timestamp);
        $date=explode('-',$date);
       return $lunar->convertSolarToLunar($date[0],$date[1],$date[2]);
        /* 返回参数示例
         * array (size=8)
  0 => string '二零一六' (length=12)
  1 => string '六月' (length=6)
  2 => string '十五' (length=6)
  3 => string '丙申' (length=6)
  4 => int 6
  5 => float 15
  6 => string '猴' (length=3)
  7 => int 0*/
     }
    //直接转化

    //农历转化为公历 参数为时间戳
    public  function  lunarToGeneral($timestamp){
        $lunar=new Lunar();
        $date=date('Y-m-d',$timestamp);
        $date=explode('-',$date);
        return $lunar->convertLunarToSolar($date[0],$date[1],$date[2]);
        /*  0 => string '2016' (length=4)
  1 => string '07' (length=2)
  2 => string '18' (length=2)
         *
         * */
    }




}